<?php
/**
 * @version SVN: $Id: stuffer.php 1221 2010-05-31 19:00:50Z elkuku $
 * @package    EasyCreator
 * @subpackage Views
 * @author     EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author     Nikolai Plath (elkuku) {@link http://www.nik-it.de NiK-IT.de}
 * @author     Created on 07-Mar-2008
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */

//-- No direct access
defined('_JEXEC') or die('=;)');

ecrLoadHelper('language');

//--Add CSS
ecrStylesheet('menu');
ecrStylesheet('stuffer');

//--Add javascript
$js = "
var LNG_DELETE = '".JText::_('Delete')."';
var LNG_SELECT = '".JText::_('Select')."';
var LNG_TEXT = '".JText::_('Text')."';
var LNG_LINK = '".JText::_('Link')."';
var LNG_IMAGE = '".JText::_('Image')."';
var LNG_ORDERING = '".JText::_('Ordering')."';
var LNG_USER_DEFINED = '".JText::_('User defined')."';";

$extProps['module'] = array('name'=>'comName', 'client'=>'scope', 'position'=>'position', 'ordering'=>'ordering');
$extProps['plugin'] = array('name'=>'comName', 'client'=>'scope', 'order'=>'ordering');

$jsAr ="var definedProjects = {".NL;

$komma1 = false;

foreach ($extProps as $eName => $eProps) :
    if( ! isset($this->projectList[$eName])) continue;

    $jsAr .=( $komma1 ) ? '  , ' : '    ';
    $komma1 = true;
    $jsAr .= "'".$eName."s' : {".NL;

    $komma2 = false;

    foreach($this->projectList[$eName] as $ext) :
        $jsAr .=( $komma2 ) ? '    , ' : '      ';
        $komma2 = true;

        $jsAr .= "'".$ext->name."' : {";

        $komma3 = false;

        foreach ($eProps as $prop=>$trans) :
            $jsAr .=( $komma3 ) ? ', ' : '';
            $komma3 = true;
            if($prop == 'client' && $ext->scope == 'frontend') $ext->scope = 'site';
            $jsAr .= "'$prop' : '".$ext->$trans."'";
        endforeach;

        $jsAr .= ' }'.NL;
    endforeach;
    $jsAr .= '    }'.NL;
endforeach;

$jsAr .= '};'.NL;

JFactory::getDocument()->addScriptDeclaration($js.NL.$jsAr);

ecrScript('addelement');
ecrScript('menu');

?>
<!-- just for js.. -->
<input type="hidden" value="0" id="totalCopys" />
<input type="hidden" value="0" id="totalSubmenu" />
<input type="hidden" value="0" id="totalPackageElementsModules" />
<input type="hidden" value="0" id="totalPackageElementsPlugins" />


<!-- Info & credits -->
<?php echo $this->loadTemplate('info'); ?>
<?php echo $this->loadTemplate('credits'); ?>

<?php
    echo $this->loadTemplate('packing');
if($this->project->type == 'component'):
    echo $this->loadTemplate('menu');
    echo $this->loadTemplate('install');
    echo $this->loadTemplate('package');
    echo $this->loadTemplate('autocode');
endif;
?>
<?php if($this->project->type == 'package') echo $this->loadTemplate('packageelements'); ?>

<?php echo $this->loadTemplate('update');
/*
<input type="hidden" name="buildvars[method]" value="<?php echo $this->project->method; ?>" />
 */
 ?>
<div style="clear: both; height: 1em;"></div>

<?php if($this->project->type == 'component'): ?>
<script type="text/javascript">
    <?php
    //--The picture chooser
    echo "drawPicChooser('', '".$this->project->menu['img']."');".NL;

    echo '//--Submenus added by PHP'.NL;

    if(isset($this->project->submenu)) :
        foreach ($this->project->submenu as $submenu) :
            echo "addSubmenu('{$submenu['text']}', '".$submenu['link']."', '".$submenu['img']."', '".$submenu['ordering']."', '{$submenu['menuid']}', '{$this->project->menu['menuid']}');".NL;
        endforeach;
    endif;

    echo '//--Package modules added by PHP'.NL;

    foreach ($this->project->modules as $module) :
        echo "addPackageElement('module', '".$module->scope."', '".$module->name."', '".$module->title."', '".$module->position."', '".$module->ordering."');".NL;
    endforeach;

    echo '//--Package plugins added by PHP'.NL;

    foreach($this->project->plugins as $plugin) :
        echo "addPackageElement('plugin', '".$plugin->scope."', '".$plugin->name."', '".$plugin->title."', '', '".$plugin->ordering."');".NL;
    endforeach;
    ?>
</script>
<?php endif; ?>

<?php
ECR_DEBUG ? ecrDebugger::varDump($this->project, '$this->project') : null;
